<?php

interface Animal
{
    public function run();

    public function say();
}

class Cat implements Animal
{
    public function run()
    {
        echo "I ran quickly <br>";
    }

    public function say()
    {
        echo "I am cat class";
    }
}

class Dog implements Animal
{
    public function run()
    {
        echo "I ran slowly <br>";
    }

    public function say()
    {
        echo "I am dog class";
    }
}

abstract class Factory
{
    abstract static function createAnimal();
}

class CatFactory extends Factory
{
    public static function createAnimal()
    {
        return new pig();
    }
}

class DogFactory extends Factory
{
    public static function createAnimal()
    {
        return new Dog();
    }
}

$cat = CatFactory::createAnimal();
$cat->say();

$dog = DogFactory::createAnimal();
$dog->say();